<?php

		$page = (int) $_POST['page'];
		
		if(!$page || $page == 0){
			echo json_encode(array('error'=>'Có lỗi xảy ra, vui lòng thử lại.'));
			exit();
		}
		
		$alias = $_POST['alias'];

		
		switch ($alias){
			case 'decu':
				$cache=new cache;
				$_GET['page'] = (int) $_POST['page'];
				$sql ="select c.id as chap_id,c.ten,c.seourl,c.index_show,m.name,m.id,m.alias,m.hinhanh from chapterk2 as c
		left join anime as m
		on c.manga=m.id 
		where c.home=1 order by ngaythem desc,c.id desc";
		$sql2="select id from chapterk2 where home=1";
			
				$pager = new Pagination($sql,5, 4, '', 300);
				$pager->setDebug(false);
				$data['decu2'] = $pager->paginate($cache,$sql2);
				foreach($data['decu2'] as $row){
					$row['ep_moinhat']=$row['ten'];
					$row['ep_moinhaturl']=mangaf1_url_manga_episode($row['chap_id'],$row['seourl']);

					$data['decu'][]=$row;
				}
			
				if(!$data['decu']){
					echo json_encode(array('error'=>'Hết dữ liệu!'));
					exit();
				}

				echo json_encode(array('content'=>manga_render_desktop_items($data['decu'])));
				break;
				case 'moi':
				$cache=new cache;
				$_GET['page'] = (int) $_POST['page'];
				
				$sql ="select id  from anime where  duyet=1 order by id desc";
				$sql2="select id from anime  where  duyet=1";
			
				$pager = new Pagination($sql,10, 4, '', 300, "anime_1");
				$pager->setDebug(false);
				$data['decu'] = $pager->paginate($cache,$sql2);
				
			
				if(!$data['decu']){
					echo json_encode(array('error'=>'Hết dữ liệu!'));
					exit();
				}

				echo json_encode(array('content'=>manga_render_desktop_items($data['decu'])));
				break;
		
			
				
		}
		exit();

  ?>